package com.irdstudio.efp.rule.service.impl;

import java.util.List;
import java.util.Objects;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.irdstudio.basic.framework.core.base.FrameworkService;
import com.irdstudio.efp.rule.service.facade.TaxAnnualPayClearInfoService;
import com.irdstudio.efp.rule.service.dao.TaxAnnualPayClearInfoDao;
import com.irdstudio.efp.rule.service.domain.TaxAnnualPayClearInfo;
import com.irdstudio.efp.rule.service.vo.TaxAnnualPayClearInfoVO;


/**
 * Service Impl: 年度汇算清缴信息表服务实现
 * @author ligm
 * @date 2019-04-29 
 */
@Service("taxAnnualPayClearInfoService")
public class TaxAnnualPayClearInfoServiceImpl implements TaxAnnualPayClearInfoService, FrameworkService {
	
	private static Logger logger = LoggerFactory.getLogger(TaxAnnualPayClearInfoServiceImpl.class);

	@Autowired
	private TaxAnnualPayClearInfoDao taxAnnualPayClearInfoDao;

   	/**
	 * 新增数据 
     * @param inTaxAnnualPayClearInfoVo
     * @return 
	 */
	public int insertTaxAnnualPayClearInfo(TaxAnnualPayClearInfoVO inTaxAnnualPayClearInfoVo) {
		logger.debug("当前新增数据为:"+ inTaxAnnualPayClearInfoVo.toString());
		int num = 0;
		try {
			TaxAnnualPayClearInfo taxAnnualPayClearInfo = new TaxAnnualPayClearInfo();
			beanCopy(inTaxAnnualPayClearInfoVo, taxAnnualPayClearInfo);
			num = taxAnnualPayClearInfoDao.insertTaxAnnualPayClearInfo(taxAnnualPayClearInfo);
		} catch (Exception e) {
			logger.error("新增数据发生异常!", e);
			num = -1;
		}
		logger.debug("当前新增数据条数为:"+ num);
		return num;
	}

    /**
	 * 根据主键删除信息 
	 * @param inTaxAnnualPayClearInfoVo
 	 * @return
	 */
	public int deleteByPk(TaxAnnualPayClearInfoVO inTaxAnnualPayClearInfoVo) {
		logger.debug("当前删除数据条件为:"+ inTaxAnnualPayClearInfoVo);
		int num = 0;
		try {
			TaxAnnualPayClearInfo taxAnnualPayClearInfo = new TaxAnnualPayClearInfo();
			beanCopy(inTaxAnnualPayClearInfoVo, taxAnnualPayClearInfo);
			num = taxAnnualPayClearInfoDao.deleteByPk(taxAnnualPayClearInfo);
		} catch (Exception e) {
			logger.error("删除数据发生异常!", e);
			num = -1;
		}
		logger.debug("根据条件:"+ inTaxAnnualPayClearInfoVo +"删除的数据条数为"+ num);
		return num;
	}


    /**
	 * 根据主键更新信息 
	 * @param inTaxAnnualPayClearInfoVo
	 * @return 
	 */  
	public int updateByPk(TaxAnnualPayClearInfoVO inTaxAnnualPayClearInfoVo) {
		logger.debug("当前修改数据为:"+ inTaxAnnualPayClearInfoVo.toString());
		int num = 0;
		try {
			TaxAnnualPayClearInfo taxAnnualPayClearInfo = new TaxAnnualPayClearInfo();
			beanCopy(inTaxAnnualPayClearInfoVo, taxAnnualPayClearInfo);
			num = taxAnnualPayClearInfoDao.updateByPk(taxAnnualPayClearInfo);
		} catch (Exception e) {
			logger.error("修改数据发生异常!", e);
			num = -1;
		}
		logger.debug("根据条件:"+ inTaxAnnualPayClearInfoVo +"修改的数据条数为"+ num);
		return num;
	}
	
    /**
	 * 根据主键查询详情 
	 * @param taxAnnualPayClearInfo
	 * @return 
	 */
	public TaxAnnualPayClearInfoVO queryByPk(TaxAnnualPayClearInfoVO inTaxAnnualPayClearInfoVo) {
		
		logger.debug("当前查询参数信息为:"+ inTaxAnnualPayClearInfoVo);
		try {
			TaxAnnualPayClearInfo queryTaxAnnualPayClearInfo = new TaxAnnualPayClearInfo();
			beanCopy(inTaxAnnualPayClearInfoVo, queryTaxAnnualPayClearInfo);
			TaxAnnualPayClearInfo queryRslTaxAnnualPayClearInfo = taxAnnualPayClearInfoDao.queryByPk(queryTaxAnnualPayClearInfo);
			if (Objects.nonNull(queryRslTaxAnnualPayClearInfo)) {
				TaxAnnualPayClearInfoVO outTaxAnnualPayClearInfoVo = beanCopy(queryRslTaxAnnualPayClearInfo, new TaxAnnualPayClearInfoVO());
				logger.debug("当前查询结果为:"+ outTaxAnnualPayClearInfoVo.toString());
				return outTaxAnnualPayClearInfoVo;
			} else {
				logger.debug("当前查询结果为空!");
			}
		} catch (Exception e) {
			logger.error("查询数据发生异常!", e);
		}
		return null;
	}


    /**
	 * 一级数据权限 
	 * @param taxAnnualPayClearInfo
	 * @return 
	 */	
	@SuppressWarnings("unchecked")
	public List<TaxAnnualPayClearInfoVO> queryAllByLevelOne(TaxAnnualPayClearInfoVO taxAnnualPayClearInfoVo) {
		logger.debug("查看当前用户对应的数据信息的参数信息为:");
		List<TaxAnnualPayClearInfoVO> list = null;
		try {
			List<TaxAnnualPayClearInfo> taxAnnualPayClearInfos = taxAnnualPayClearInfoDao.queryAllByLevelOneByPage(taxAnnualPayClearInfoVo);
			logger.debug("查看当前用户对应的数据信息的结果集数量为:"+ taxAnnualPayClearInfos.size());
			pageSet(taxAnnualPayClearInfos, taxAnnualPayClearInfoVo);
			list = (List<TaxAnnualPayClearInfoVO>) beansCopy(taxAnnualPayClearInfos, TaxAnnualPayClearInfoVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
		}
		
		return list;
	
	}


    /**
	 * 二级数据权限 
	 * @param taxAnnualPayClearInfo
	 * @return 
	 */
	@SuppressWarnings("unchecked")
	public List<TaxAnnualPayClearInfoVO> queryAllByLevelTwo(TaxAnnualPayClearInfoVO taxAnnualPayClearInfoVo) {
		logger.debug("查看当前用户及所属机构对应的数据信息的参数信息为:");
		List<TaxAnnualPayClearInfo> taxAnnualPayClearInfos = taxAnnualPayClearInfoDao.queryAllByLevelTwoByPage(taxAnnualPayClearInfoVo);
		logger.debug("查看当前用户及所属机构对应的数据信息的结果集数量为:"+taxAnnualPayClearInfos.size());
		List<TaxAnnualPayClearInfoVO> list = null;
		try {
			pageSet(taxAnnualPayClearInfos, taxAnnualPayClearInfoVo);
			list = (List<TaxAnnualPayClearInfoVO>) beansCopy(taxAnnualPayClearInfos, TaxAnnualPayClearInfoVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
		}
		
		return list;
	
	}


    /**
	 * 三级数据权限 
	 * @param taxAnnualPayClearInfo
	 * @return 
	 */
	@SuppressWarnings("unchecked")
	public List<TaxAnnualPayClearInfoVO> queryAllByLevelThree(TaxAnnualPayClearInfoVO taxAnnualPayClearInfoVo) {
		logger.debug("查看当前用户所在机构及下属机构对应的数据信息的参数信息为:");
		List<TaxAnnualPayClearInfo> taxAnnualPayClearInfos = taxAnnualPayClearInfoDao.queryAllByLevelThreeByPage(taxAnnualPayClearInfoVo);
		logger.debug("查看当前用户所在机构及下属机构对应的数据信息的结果集数量为:"+ taxAnnualPayClearInfos.size());
		List<TaxAnnualPayClearInfoVO> list = null;
		try {
			pageSet(taxAnnualPayClearInfos, taxAnnualPayClearInfoVo);
			list = (List<TaxAnnualPayClearInfoVO>) beansCopy(taxAnnualPayClearInfos, TaxAnnualPayClearInfoVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
		}
		
		return list;
	}

    /**
	 * 四级数据权限  
	 * @param taxAnnualPayClearInfo
	 * @return 
	 */
	@SuppressWarnings("unchecked")
	public List<TaxAnnualPayClearInfoVO> queryAllByLevelFour(TaxAnnualPayClearInfoVO taxAnnualPayClearInfoVo) {
		logger.debug("【预留，便于后续自定义 】信息的参数信息为:");
		List<TaxAnnualPayClearInfo> taxAnnualPayClearInfos = taxAnnualPayClearInfoDao.queryAllByLevelFourByPage(taxAnnualPayClearInfoVo);
		logger.debug("【预留，便于后续自定义 】信息的结果集数量为:"+ taxAnnualPayClearInfos.size());
		List<TaxAnnualPayClearInfoVO> list = null;
		try {
			pageSet(taxAnnualPayClearInfos, taxAnnualPayClearInfoVo);
			list = (List<TaxAnnualPayClearInfoVO>) beansCopy(taxAnnualPayClearInfos, TaxAnnualPayClearInfoVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
		}
		
		return list;
	}

    /**
	 * 五级数据权限  
	 * @param taxAnnualPayClearInfo
	 * @return 
	 */
	@SuppressWarnings("unchecked")
	public List<TaxAnnualPayClearInfoVO> queryAllByLevelFive(TaxAnnualPayClearInfoVO taxAnnualPayClearInfoVo) {
		logger.debug("【预留，便于后续自定义 】信息的参数信息为:");
		List<TaxAnnualPayClearInfo> taxAnnualPayClearInfos = taxAnnualPayClearInfoDao.queryAllByLevelFiveByPage(taxAnnualPayClearInfoVo);
		logger.debug("【预留，便于后续自定义 】信息的结果集数量为:"+ taxAnnualPayClearInfos.size());
		List<TaxAnnualPayClearInfoVO> list = null;
		try {
			pageSet(taxAnnualPayClearInfos, taxAnnualPayClearInfoVo);
			list = (List<TaxAnnualPayClearInfoVO>) beansCopy(taxAnnualPayClearInfos, TaxAnnualPayClearInfoVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
		}
		
		return list;
	}
}
